package controllers

import (
	"github.com/gin-gonic/gin"
	"gowww/comeon/services"
	"net/http"
)

//
//  List
//  @Description: 菜单目录列表
//  @param c
//
func MenuList(c *gin.Context) {
	var menuService services.MenuList
	c.BindJSON(&menuService)
	retData := menuService.List()
	c.JSON(http.StatusOK, gin.H{"code": 0, "data": retData})
}

//
//  MenuAdd
//  @Description: 菜单添加
//  @param c
//
func MenuAdd(c *gin.Context) {
	var menuService services.MenuAdd
	c.ShouldBindJSON(&menuService)
	err := menuService.Add()
	errCode, errInfo := 0, "success"
	if err != nil {
		errCode = 10001
		errInfo = err.Error()
	}
	c.JSON(http.StatusOK, gin.H{
		"code":    errCode,
		"message": errInfo,
	})
}
